package com.xiaohe66.web.application.sys.sec;

import com.xiaohe66.common.web.sec.annotation.NeedLogin;
import com.xiaohe66.web.application.sys.sec.result.AccountInfoResult;
import com.xiaohe66.web.domain.sys.sec.entity.CurrentAccount;
import com.xiaohe66.web.domain.sys.sec.service.SecurityService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author He
 * @since 2024.01.15 16:48
 */
@Service
@RequiredArgsConstructor
public class AccountAppService {

    private final SecurityService securityService;

    @NeedLogin
    public AccountInfoResult currentUserInfo() {

        CurrentAccount currentAccount = securityService.getCurrentAccount();

        AccountInfoResult result = new AccountInfoResult();
        result.setId(currentAccount.getId().getValue());
        result.setUsername(currentAccount.getName().getValue());

        return result;
    }
}
